package com.zsh.config;

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Isolation;

/**
 * @author zsh
 * @Description
 * @create 2022-02-11 12:40
 */

@MapperScan("com.zsh.mapper") //扫描Mapper文件
@EnableTransactionManagement
@Configuration //配置类
public class MybatisPlusConfig {
    /**
     * 旧版
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }

    /**
     * 逻辑删除组件
     */
    @Bean
    public ISqlInjector sqlInjector(){
        return new LogicSqlInjector();
    }


    /**
     * 配置分页插件
     */
//    @Bean
//    public PaginationInterceptor paginationInterceptor(){
//        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
//    return 0;
//        //设置请求的页面大于最大页的操作，true回到首页，false继续请求，默认false
//        //paginationInterceptor.setOverflow(false);
//        //设置最大单页限制数量，默认500条，-1 不受限制
////        paginationInterceptor.setLimit();
////        paginationInterceptor.setC
//    }
}
